<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title>
  <script type="text/javascript" src="./vue.js"></script>
</head>

<body>
  <div id="app">
    {{count}}
    <button @click="add1">没有括号</button>
    <button @click="add2($event)">有括号没参数</button>
    <button @click="add3(5)">有括号有参数</button>
  </div>
</body>
<script type="text/javascript">
  Vue.config.productionTip = false;
  const vm = new Vue({
    el: "#app",
    data() {
      return {
        count: 0
      }
    },
    methods: {
      add1() {
        console.log(this);
        console.log(this.count);
        this.count++
      },
      add2(e) {
        //使用$event 可以捕获事件对象
        console.log(this,"this");
        console.log(e,"e");
        console.log(this.count);
        this.count++
      },
      add3(a) {
        this.count+=a
      }
    }
  })
</script>

</html>